//
// Copyright (C) 2011 Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.101
//#include "stdafx.h"
#include "HistoricalForwardRatesAnalysis.h"
using namespace Cephei::QL::Models::Marketmodels;
#include <gen/QL/Times/Period.h>
using namespace Cephei::QL::Times;
#undef HANDLE
#define ABSTRACT
#undef STRUCT
Cephei::QL::Models::Marketmodels::CHistoricalForwardRatesAnalysis::CHistoricalForwardRatesAnalysis (boost::shared_ptr<QuantLib::HistoricalForwardRatesAnalysis>& childNative, Object^ owner) 
{
	_pSpinlock = new boost::detail::spinlock ();
#ifdef HANDLE
	_phHistoricalForwardRatesAnalysis = NULL;
#endif
	_ppHistoricalForwardRatesAnalysis = &childNative;
    
}
Cephei::QL::Models::Marketmodels::CHistoricalForwardRatesAnalysis::CHistoricalForwardRatesAnalysis (QuantLib::HistoricalForwardRatesAnalysis& childNative, Object^ owner) 
{
#ifdef HANDLE
	_phHistoricalForwardRatesAnalysis = NULL;
#endif
	_ppHistoricalForwardRatesAnalysis = new boost::shared_ptr<QuantLib::HistoricalForwardRatesAnalysis> (&childNative);
    
    _HistoricalForwardRatesAnalysisOwner = owner;
    
}

Cephei::QL::Models::Marketmodels::CHistoricalForwardRatesAnalysis::CHistoricalForwardRatesAnalysis (CHistoricalForwardRatesAnalysis^ copy) 
{
	_pSpinlock = new boost::detail::spinlock ();
#ifdef HANDLE
	_phHistoricalForwardRatesAnalysis = NULL;
#endif
	if (copy->HasNative() != NULL)
    {
		_ppHistoricalForwardRatesAnalysis = new boost::shared_ptr<QuantLib::HistoricalForwardRatesAnalysis> (copy->GetShared());
        
    }
}
Cephei::QL::Models::Marketmodels::CHistoricalForwardRatesAnalysis::CHistoricalForwardRatesAnalysis (System::Type^ t) 
{
	_pSpinlock = new boost::detail::spinlock ();
#ifdef HANDLE
	_phHistoricalForwardRatesAnalysis = NULL;
#endif
	if (!t->IsSubclassOf(CHistoricalForwardRatesAnalysis::typeid))
		throw gcnew Exception ("Invalid base-case init");
}
#ifdef HANDLE
Cephei::QL::Models::Marketmodels::CHistoricalForwardRatesAnalysis::CHistoricalForwardRatesAnalysis (QuantLib::Handle<QuantLib::HistoricalForwardRatesAnalysis>& childNative, Object^ owner)  
{
	_pSpinlock = new boost::detail::spinlock ();
	_phHistoricalForwardRatesAnalysis = &childNative;
	_ppHistoricalForwardRatesAnalysis = &static_cast<boost::shared_ptr<QuantLib::HistoricalForwardRatesAnalysis>>(childNative.currentLink());
    
    _HistoricalForwardRatesAnalysisOwner = owner;
}
Cephei::QL::Models::Marketmodels::CHistoricalForwardRatesAnalysis::CHistoricalForwardRatesAnalysis (QuantLib::Handle<QuantLib::HistoricalForwardRatesAnalysis> childNative)  
{
	_pSpinlock = new boost::detail::spinlock ();
	_phHistoricalForwardRatesAnalysis = &childNative;
	_ppHistoricalForwardRatesAnalysis = &static_cast<boost::shared_ptr<QuantLib::HistoricalForwardRatesAnalysis>>(childNative.currentLink());
    
}
#endif
#ifdef STRUCT
Cephei::QL::Models::Marketmodels::CHistoricalForwardRatesAnalysis::CHistoricalForwardRatesAnalysis (QuantLib::HistoricalForwardRatesAnalysis childNative)  
{
	_pSpinlock = new boost::detail::spinlock ();
#ifdef HANDLE
	_phHistoricalForwardRatesAnalysis = NULL;
#endif
	_ppHistoricalForwardRatesAnalysis = new boost::shared_ptr<QuantLib::HistoricalForwardRatesAnalysis> (new QuantLib::HistoricalForwardRatesAnalysis (childNative));
    
}
#endif

Cephei::QL::Models::Marketmodels::CHistoricalForwardRatesAnalysis::~CHistoricalForwardRatesAnalysis ()
{
	if (_pSpinlock != NULL)
    {
        delete _pSpinlock;
        _pSpinlock = NULL;
    }
    if (_ppHistoricalForwardRatesAnalysis != NULL)
    {
	    delete _ppHistoricalForwardRatesAnalysis;
        _ppHistoricalForwardRatesAnalysis = NULL;
    }
}
Cephei::QL::Models::Marketmodels::CHistoricalForwardRatesAnalysis::!CHistoricalForwardRatesAnalysis ()
{
	if (_pSpinlock != NULL)
    {
        delete _pSpinlock;
    }
    if (_ppHistoricalForwardRatesAnalysis != NULL)
    {
	    delete _ppHistoricalForwardRatesAnalysis;
    }
}
QuantLib::HistoricalForwardRatesAnalysis& Cephei::QL::Models::Marketmodels::CHistoricalForwardRatesAnalysis::GetReference ()
{
    if (_ppHistoricalForwardRatesAnalysis == NULL) throw gcnew NativeNullException ();
	return **_ppHistoricalForwardRatesAnalysis;
}
boost::shared_ptr<QuantLib::HistoricalForwardRatesAnalysis>& Cephei::QL::Models::Marketmodels::CHistoricalForwardRatesAnalysis::GetShared ()
{
    if (_ppHistoricalForwardRatesAnalysis == NULL) throw gcnew NativeNullException ();
	return *_ppHistoricalForwardRatesAnalysis;
}
QuantLib::HistoricalForwardRatesAnalysis* Cephei::QL::Models::Marketmodels::CHistoricalForwardRatesAnalysis::GetPointer ()
{
    if (_ppHistoricalForwardRatesAnalysis == NULL) throw gcnew NativeNullException ();
	return &**_ppHistoricalForwardRatesAnalysis;
}
#ifdef HANDLE
QuantLib::Handle<QuantLib::HistoricalForwardRatesAnalysis>& Cephei::QL::Models::Marketmodels::CHistoricalForwardRatesAnalysis::GetHandle ()
{
	if (_phHistoricalForwardRatesAnalysis == NULL)
	{
		_phHistoricalForwardRatesAnalysis = new Handle<QuantLib::HistoricalForwardRatesAnalysis> (*_ppHistoricalForwardRatesAnalysis);
	}
	return *_phHistoricalForwardRatesAnalysis;
}
#endif
bool Cephei::QL::Models::Marketmodels::CHistoricalForwardRatesAnalysis::HasNative () 
{
	return (_ppHistoricalForwardRatesAnalysis != NULL);
}

Cephei::IVector<DateTime>^ Cephei::QL::Models::Marketmodels::CHistoricalForwardRatesAnalysis::FailedDates::get ()
{
    try
    {
    	std::vector<QuantLib::Date>& _rv = (std::vector<QuantLib::Date>&)(*_ppHistoricalForwardRatesAnalysis)->failedDates ( );   
        Cephei::IVector<DateTime>^ _nrv = gcnew CoVector<DateTime> (gcnew CDateTimeVector (_rv));
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::IVector<String^>^ Cephei::QL::Models::Marketmodels::CHistoricalForwardRatesAnalysis::FailedDatesErrorMessage::get ()
{
    try
    {
    	std::vector<std::string>& _rv = (std::vector<std::string>&)(*_ppHistoricalForwardRatesAnalysis)->failedDatesErrorMessage ( );   
        Cephei::IVector<String^>^ _nrv = gcnew CoVector<String^> (gcnew CStringVector (_rv));
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::IVector<Cephei::QL::Times::IPeriod^>^ Cephei::QL::Models::Marketmodels::CHistoricalForwardRatesAnalysis::FixingPeriods::get ()
{
    try
    {
    	std::vector<QuantLib::Period>& _rv = (std::vector<QuantLib::Period>&)(*_ppHistoricalForwardRatesAnalysis)->fixingPeriods ( );   
        CoVector<Cephei::QL::Times::IPeriod^>^ _nrv = gcnew CoVector<Cephei::QL::Times::IPeriod^>(gcnew CPeriodVector (_rv, this));
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::IVector<DateTime>^ Cephei::QL::Models::Marketmodels::CHistoricalForwardRatesAnalysis::SkippedDates::get ()
{
    try
    {
    	std::vector<QuantLib::Date>& _rv = (std::vector<QuantLib::Date>&)(*_ppHistoricalForwardRatesAnalysis)->skippedDates ( );   
        Cephei::IVector<DateTime>^ _nrv = gcnew CoVector<DateTime> (gcnew CDateTimeVector (_rv));
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::IVector<String^>^ Cephei::QL::Models::Marketmodels::CHistoricalForwardRatesAnalysis::SkippedDatesErrorMessage::get ()
{
    try
    {
    	std::vector<std::string>& _rv = (std::vector<std::string>&)(*_ppHistoricalForwardRatesAnalysis)->skippedDatesErrorMessage ( );   
        Cephei::IVector<String^>^ _nrv = gcnew CoVector<String^> (gcnew CStringVector (_rv));
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Factory class

